package numerics;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class LinearRegressionIO {

	public static List<double[]> parseInputFile(String inputPath)
			throws WrongFileFormatException {
		List<double[]> data = new ArrayList<double[]>();
		Scanner sc;
		try {
			sc = new Scanner(new File(inputPath));
		} catch (FileNotFoundException e) {
			System.out.println(e.toString());
			return null;
		}

		double d_temp;
		while (sc.hasNextDouble()) {
			d_temp = sc.nextDouble();
			if (sc.hasNextDouble())
				data.add(new double[] { d_temp, sc.nextDouble() });
			else
				throw new WrongFileFormatException();
		}
		
		return data;
	}
}
